//
//  HLIMKitSessionConfigurator.m
//  YueYue
//
//  Created by hulu001 on 2024/1/11.
//

#import "HLIMKitSessionConfigurator.h"
#import "HLBaseSessionViewController.h"
#import "HLIMKitSessionTableAdapter.h"
#import "HLIMKitSessionLayoutImpl.h"
#import "HLIMKitSessionInteractorImpl.h"
#import "HLIMKitSessionDataSourceImpl.h"
#import <NIMSDK/NIMMessage.h>

@interface HLIMKitSessionConfigurator ()

@property (nonatomic, strong) HLIMKitSessionInteractorImpl   *interactor;
@property (nonatomic, strong) HLIMKitSessionTableAdapter     *tableAdapter;

@end

@implementation HLIMKitSessionConfigurator

- (void)dealloc
{
}

- (void)setup:(HLBaseSessionViewController *)sessionVC
{
//    TIOSession *session = sessionVC.session;
    
    HLIMKitSessionDataSourceImpl *dataSource = [HLIMKitSessionDataSourceImpl.alloc initWithSession:sessionVC.session sessionConfig:sessionVC.sessionConfig];
    HLIMKitSessionLayoutImpl *layout = [HLIMKitSessionLayoutImpl.alloc initWithSession:sessionVC.session sessionConfig:[sessionVC sessionConfig]];
    layout.tableView = sessionVC.tableView;
    layout.inputView = sessionVC.sessionInputView;
    
    _interactor = [HLIMKitSessionInteractorImpl.alloc initWithSession:sessionVC.session sessionConfig:[sessionVC sessionConfig]];
    _interactor.dataSource = dataSource;
    _interactor.layout = layout;
    _interactor.delegate = sessionVC;
    
    [layout setDelegate:_interactor];
    
    _tableAdapter = [HLIMKitSessionTableAdapter.alloc init];
    _tableAdapter.interactor = _interactor;
    _tableAdapter.delegate = sessionVC;
    
    sessionVC.tableView.dataSource = _tableAdapter;
    sessionVC.tableView.delegate = _tableAdapter;
    
    [sessionVC setInteractor:_interactor];
    [_interactor resetLayout];
}

@end
